﻿@inject IExceptionService ExceptionService
@inject ICms Cms

<div class="content">
    <p><strong>Error</strong></p>
    <p>An errror occured when your request was made.</p>
    <p><a href="/" class="btn btn-primary">Return to home and start again.</a></p>
</div>

@{
    if (Cms.IsDevelopment)
    {
        var ex = ExceptionService.GetLatestException();

        if (ex != null)
        {
            <div class="content">
                <p><code>@ex.Message</code></p>

                <pre>@ex.StackTrace</pre>

                @{
                    var innerException = ex.InnerException;

                    while (innerException != null)
                    {
                        <p><code>@innerException.Message</code></p>

                        innerException = innerException.InnerException;
                    }
                }
            </div>
        }
    }
    else
    {
        <div class="content">
            <p>To enable exception view, set <code>isDevelopment</code>:</p>
            <pre>app.UseRapidCMS(isDevelopment: env.IsDevelopment());</pre>
        </div>
    }
}